package at.jsug.topicvoting.gwt1.client.logic.controller;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.PopupPanel;

import at.jsug.topicvoting.gwt1.client.logic.IEventListener;
import at.jsug.topicvoting.gwt1.client.logic.event.NewTopicEvent;
import at.jsug.topicvoting.gwt1.client.view.NewTopicDialog;

public class NewTopicCommand implements IEventListener<NewTopicEvent> {

	public void eventReceived(NewTopicEvent event) {
		System.out.println("NewTopicCommand.eventReceived(event="+event+")");
		
		final NewTopicDialog popup = new NewTopicDialog();
		
		popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
			public void setPosition(int offsetWidth, int offsetHeight) {
				int left = (Window.getClientWidth() - offsetWidth) / 3;
				int top = (Window.getClientHeight() - offsetHeight) / 3;
				popup.setPopupPosition(left, top);
			}
		});
		
	}

}
